
**** Figure 1 
* Panel A: Risk

use $pathdata/Risk/Risk_cleaned.dta, clear


preserve
keep if baseline==1 & gains==1
replace ce=ce/100
replace lottery_prob=lottery_prob/100

nl (ce = {d=1}*lottery_prob^{g=1}/({d}*lottery_prob^{g}+(1-lottery_prob)^{g})) if baseline==1 & gains==1, cl(id)
local d = _b[/d]
local g = _b[/g]

collapse (mean) ce  (count) no=ce, by(lottery_prob)


twoway 	(function  y=x, lpattern(dash) lcolor(black)) ///
		(function  y=`d'*x^`g' / (`d'*x^`g' + (1-x)^`g'), range(0 1) lcolor(black) lwidth(thick) ), ///
		title("Choice under risk", color(black)) ///
		ytitle("Implied probability weight") ///
		xtitle("Payoff probability") ///
		graphregion(color(white)) legend(off) 	ylabel(0(0.25)1, angle(0) nogrid glwidth(thin)) ///
		xsize(8) ysize(8) xlabel(0(0.25)1)

		
		
* Panel B: Belief updating

use $pathdata/Beliefs/Beliefs_cleaned.dta, clear


keep if baseline_set==1

qui gen p = round_bayesian_posterior / 100
qui gen c = belief/100

nl (c = {d=1}*p^{g=1}/({d}*p^{g}+(1-p)^{g})) if baseline_set ==1, cl(id)
local d = _b[/d]
local g = _b[/g]

twoway 	(function y =x, lpattern(dash) lcolor(black)) ///
		(function  y=`d'*x^`g' / (`d'*x^`g' + (1-x)^`g'), droplines(1) base(1) range(0 1) lcolor(black) lwidth(thick) ), ///
		title("Belief updating", color(black)) ///
		ytitle("Stated posterior") ///
		xtitle("Bayesian posterior") ///
		graphregion(color(white)) legend(off) 	ylabel(0(0.25)1, angle(0) nogrid glwidth(thin)) ///
		xsize(8) ysize(8) xlabel(0(0.25)1)

restore
	

		
		
* Panel C: Stock market 

use $pathdata/Survey_exp/Survey_cleaned.dta, clear
keep if task_type == "stocks"
gen b = belief /100
gen p = true_percentile/100
nl (b = {d=1}*p^{g=1}/({d}*p^{g}+(1-p)^{g})), cl(id)
local d = _b[/d]
local g = _b[/g]


twoway 	(function  y=x, lpattern(dash) lcolor(black)) ///
		(function  y=`d'*x^`g' / (`d'*x^`g' + (1-x)^`g'), range(0 1) lcolor(black) lwidth(thick) ), ///
		title("Stock market expectations", color(black)) ///
		ytitle("Stated probability") ///
		xtitle("True probability") ///
		graphregion(color(white)) legend(off) 	ylabel(0(0.25)1, angle(0) nogrid glwidth(thin)) ///
		xsize(8) ysize(8) xlabel(0(0.25)1)

